﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ValidationFramework.Reflection;

namespace ValidationFramework.Configuration.Fluent
{
	/// <summary>
	/// Represents the location of a rule.
	/// </summary>
	public class RuleLocation
	{
		/// <summary>
		/// Initializes a new instance of the RuleLocation class.
		/// </summary>
		public RuleLocation(IValidationPolicy policy)
		{
			this.ValidationPolicy = policy;
		}

		/// <summary>
		/// Make this inernal so it can't be seen by consumers using the fluent API.
		/// </summary>
		/// <returns></returns>
		internal Rule CreateRule(ISpecification validator)
		{
			var rule = new Rule(validator);
			rule.RuleSet = RuleSet;
			var newrule = ValidationPolicy.AddRule(rule, RuleScope);
			return newrule;
		}

		/// <summary>
		/// The policy the rule will be added too
		/// </summary>
		internal IValidationPolicy ValidationPolicy { get; set; }
		/// <summary>
		/// The scope of the rule when its added to the descriptor
		/// </summary>
		internal RuleScope RuleScope { get; set; }
		internal string RuleSet { get; set; }
	}
}
